package com.ydd.service.impl;

import com.ydd.constant.MessageConstant;
import com.ydd.dto.LikeDTO;
import com.ydd.entity.YddUserData;
import com.ydd.mapper.YddUserDataMapper;
import com.ydd.result.Result;
import com.ydd.service.IYddUserDataService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author itcast
 * @since 2023-05-15
 */
@Service
public class YddUserDataServiceImpl extends ServiceImpl<YddUserDataMapper, YddUserData> implements IYddUserDataService {
    @Autowired
    private YddUserDataMapper yddUserDataMapper;


    /**
     * 点赞取消点赞和收藏
     *
     * @param dto
     * @return
     */
    @Override
    public Result userDataHandle(LikeDTO dto) {
        if (dto.getType() == null || dto.getArticle_id() == null) {
            return Result.error(MessageConstant.UNKNOWN_ERROR);
        }
        yddUserDataMapper.userDataHandle(dto);
        return Result.success();
    }
}
